#include "TcpServer.hpp"
#include "daemon.hpp"
#include <memory>
using namespace Server;
using namespace std;

static void Usage(string msg)
{
    cout << "\nUsage:\n\t" << msg << " local_port\n\n"
         << endl;
}

// ./tcpserver 端口号(8080)
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port = atoi(argv[1]);

    unique_ptr<TcpServer> uts(new TcpServer(port));
    uts->InitTcpServer();

    //变成守护进程
    daemonSelf();
    uts->Start();
    return 0;
}